; 快速排序法
(define (filter predicate lst)
  (if (eq? '() lst)
      '()
      (if (predicate (car lst))
          (cons (car lst) (filter predicate (cdr lst)))
          (filter predicate (cdr lst)))))

(define (qsort lst)
  (if (eq? '() lst)
      '()
      (append (qsort (filter (lambda (x) (< x (car lst))) (cdr lst)))
              (list (car lst))
              (qsort (filter (lambda (x) (> x (car lst))) (cdr lst))))))
